home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gxtype1.h < prev    next >
C/C++ Source or Header  |  1993-05-13  |  7KB  |  163 lines

  1. /* Copyright (C) 1990, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gxtype1.h */
  20. /* Private Adobe Type 1 font definitions for Ghostscript library */
  21. #include "gscrypt1.h"
  22. #include "gstype1.h"
  23.  
  24. /* This file defines the structures for the state of a Type 1 interpreter. */
  25.  
  26. /*
  27.  * Because of oversampling, one pixel in the Type 1 interpreter may
  28.  * correspond to several device pixels.  This is also true of the hint data,
  29.  * since the CTM reflects the transformation to the oversampled space.
  30.  * To help keep the font level hints separated from the character level hints,
  31.  * we store the scaling factor separately with each set of hints.
  32.  */
  33. typedef struct pixel_scale_s {
  34.     fixed unit;        /* # of pixels per device pixel */
  35.     fixed half;        /* unit / 2 */
  36.     int log2_unit;        /* log2(unit / fixed_1) */
  37. } pixel_scale;
  38. #define set_pixel_scale(pps, log2)\
  39.   (pps)->half = ((pps)->unit = fixed_1 << ((pps)->log2_unit = log2)) >> 1
  40. #define scaled_rounded(v, pps)\
  41.   (((v) + (pps)->half) & -(pps)->unit)
  42.  
  43. /* ------ Font level hints ------ */
  44.  
  45. /* Define the standard stem width tables. */
  46. /* Each table is sorted, since the StemSnap arrays are sorted. */
  47. #define max_snaps (1 + max_StemSnap)
  48. typedef struct {
  49.     int count;
  50.     fixed data[max_snaps];
  51. } stem_snap_table;
  52.  
  53. /* Define the alignment zone structure. */
  54. /* These are in device coordinates also. */
  55. #define max_a_zones (max_BlueValues + max_OtherBlues)
  56. typedef struct {
  57.     int is_top_zone;
  58.     fixed v0, v1;            /* range for testing */
  59.     fixed flat;            /* flat position */
  60. } alignment_zone;
  61.  
  62. /* Define the structure for hints that depend only on the font and CTM, */
  63. /* not on the individual character.  Eventually these should be cached */
  64. /* with the font/matrix pair. */
  65. typedef struct font_hints_s {
  66.     int axes_swapped;        /* true if x & y axes interchanged */
  67.                     /* (only set if using hints) */
  68.     int x_inverted, y_inverted;    /* true if axis is inverted */
  69.     int use_x_hints;        /* true if we should use hints */
  70.                     /* for char space x coords (vstem) */
  71.     int use_y_hints;        /* true if we should use hints */
  72.                     /* for char space y coords (hstem) */
  73.     pixel_scale scale;        /* oversampling scale */
  74.     stem_snap_table snap_h;        /* StdHW, StemSnapH */
  75.     stem_snap_table snap_v;        /* StdVW, StemSnapV */
  76.     fixed blue_fuzz, blue_shift;    /* alignment zone parameters */
  77.                     /* in device pixels */
  78.     int suppress_overshoot;        /* (computed from BlueScale) */
  79.     int a_zone_count;        /* # of alignment zones */
  80.     alignment_zone a_zones[max_a_zones];    /* the alignment zones */
  81. } font_hints;
  82.  
  83. /* ------ Character level hints ------ */
  84.  
  85. /* Define the stem hint tables. */
  86. /* Each stem hint table is kept sorted. */
  87. /* Stem hints are in device coordinates. */
  88. #define max_stems 6            /* arbitrary */
  89. typedef struct {
  90.     fixed v0, v1;            /* coordinates (widened a little) */
  91.     fixed dv0, dv1;            /* adjustment values */
  92. } stem_hint;
  93. typedef struct {
  94.     int count;
  95.     stem_hint *current;        /* cache cursor for search */
  96.     stem_hint data[max_stems];
  97. } stem_hint_table;
  98.  
  99. /* ------ Interpreter state ------ */
  100.  
  101. /* Define the control state of the interpreter. */
  102. /* This is what must be saved and restored */
  103. /* when calling a CharString subroutine. */
  104. typedef struct {
  105.     const byte *ip;
  106.     crypt_state dstate;
  107. } ip_state;
  108.  
  109. /* This is the full state of the Type 1 interpreter. */
  110. #define ostack_size 24            /* per documentation */
  111. #define ipstack_size 10            /* per documentation */
  112. struct gs_type1_state_s {
  113.         /* The following are set at initialization */
  114.     gs_show_enum *penum;        /* show enumerator */
  115.     gs_state *pgs;            /* graphics state */
  116.     gs_type1_data *pdata;        /* font-specific data */
  117.     int charpath_flag;        /* 0 for show, 1 for false */
  118.                     /* charpath, 2 for true charpath */
  119.     int paint_type;            /* 0/3 for fill, 1/2 for stroke */
  120.     fixed_coeff fc;            /* cached fixed coefficients */
  121.     float flatness;            /* flatness for character curves */
  122.     pixel_scale scale;        /* oversampling scale */
  123.     font_hints fh;            /* font-level hints */
  124.         /* The following are updated dynamically */
  125.     fixed ostack[ostack_size];    /* the Type 1 operand stack */
  126.     int os_count;            /* # of occupied stack entries */
  127.     ip_state ipstack[ipstack_size+1];    /* control stack */
  128.     int ips_count;            /* # of occupied entries */
  129.     int sb_set;            /* true if lsb is preset */
  130.     gs_fixed_point lsb;        /* left side bearing */
  131.     gs_fixed_point width;        /* character width (char coords) */
  132.     int seac_base;            /* base character code for seac, */
  133.                     /* or -1 */
  134.     gs_fixed_point position;    /* save unadjusted position */
  135.                     /* when returning temporarily */
  136.                     /* to caller */
  137.     int flex_path_was_open;        /* record whether path was open */
  138.                     /* at start of Flex section */
  139. #define flex_max 8
  140.     gs_fixed_point flex_points[flex_max];    /* points for Flex */
  141.     int flex_count;
  142.         /* The following are set dynamically. */
  143.     int in_dotsection;        /* true if inside dotsection */
  144.     int vstem3_set;            /* true if vstem3 seen */
  145.     gs_fixed_point vs_offset;    /* device space offset for centering */
  146.                     /* middle stem of vstem3 */
  147.     stem_hint_table hstem_hints;    /* horizontal stem hints */
  148.     stem_hint_table vstem_hints;    /* vertical stem hints */
  149. };
  150.  
  151. /* ------ Interface between main Type 1 interpreter and hint routines ------ */
  152.  
  153. /* Font level hints */
  154. extern void compute_font_hints(P4(font_hints *, const gs_matrix_fixed *,
  155.                   int, const gs_type1_data *));
  156. /* Character level hints */
  157. extern void reset_stem_hints(P1(gs_type1_state *));
  158. extern void find_stem_hints(P6(gs_type1_state *, fixed, fixed,
  159.                    fixed, fixed, gs_fixed_point *));
  160. extern void type1_hstem(P3(gs_type1_state *, fixed, fixed));
  161. extern void type1_vstem(P3(gs_type1_state *, fixed, fixed));
  162. extern void center_vstem(P3(gs_type1_state *, fixed, fixed));
  163.